﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Security.Policy;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;

namespace WindowsFormsApplication1
{
    public partial class SetBaud : Form
    {
        public SetBaud(Action<int, int,int,int > a)
        {
            SetBaudType = a;
            InitializeComponent();
        }
        Action<int, int,int,int > SetBaudType;
        private void SetBaud_Load(object sender, EventArgs e)
        {
            comboBox1.SelectedIndex = 0;
            comboBox2.SelectedIndex = 1;
            Form1.ComBaudRate = 9600;
        }

        private void ButSet16_Click(object sender, EventArgs e)
        {
            int a = 0, b = 2, c, d;
            c = Convert.ToInt32(comboBox1.Text);
            switch (comboBox2.Text)  //校验位
            {
                case "None": d = 0; break;
                case "Odd": d = 1; break;
                case "Even": d = 2; break;
                default: d = 0; break;
            }
            SetBaudType(a,b,c,d);
        }

        private void button1_Click(object sender, EventArgs e)
        {

        }
    }
}
